/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Principal;

import java.util.List;
import java.util.Vector;
import javax.swing.DefaultListModel;

/**
 *
 * @author EliteBook
 */
public class restarEspecialDelCarro extends javax.swing.JDialog {

    /**
     * Creates new form restarEspecialDelCarro
     */
    Vector especiales;
    Vector especialesId;

    private final DefaultListModel modelo1;

    public restarEspecialDelCarro(java.awt.Frame parent, boolean modal, int code, Vector esp, Vector espid, String tipo) {
        super(parent, modal);
        initComponents();
        cual.setText("¿Qué " + tipo + " vas a restar?");
        especiales = esp;
        especialesId = espid;
        modelo1 = new DefaultListModel();
        jList1.setModel(modelo1);
        for (int i = 0; i < especiales.size(); i++) {
            if ((int) especialesId.get(i) == code) {
                modelo1.addElement(especiales.get(i));
            }
        }

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        cual = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jList1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jList1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jList1);

        cual.setText("¿Que chip quieres quitar?");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cual)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cual)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
        if (evt.getClickCount() == 2) {
            if (!jList1.isSelectionEmpty()) {
                String clave;
                int id;
                List<String> claves = jList1.getSelectedValuesList();
                for (String clave1 : claves) {
                    clave = clave1;
                    id=especiales.indexOf(clave);
                    especiales.removeElementAt(id);
                    especialesId.removeElementAt(id);
                }
                this.dispose();
            }
        }

// TODO add your handling code here:
    }//GEN-LAST:event_jList1MouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel cual;
    private javax.swing.JList jList1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
